package feevale.dropbox.util;

public enum Protocol {
	
	LIST("LST"),
	DOWNLOAD("DWN"),
	UPLOAD("UPL"),
	UPLOAD_CONFIRMATION("UPC"),
	LIST_DELETED_FILES("LDF"),
	LIST_DELETED_CONFIRMATION("LDC"),
	LIST_EXISTENT_FILES("LEF"),
	LIST_EXISTENT_CONFIRMATION("LEC"),
	DELETE("DEL"),
	DELETE_CONFIRMATION("DEC");
	
	private String key;
	
	Protocol(String key) {
		this.key = key;
	}
	
	public String getKey() {
		return key;
	}
	
	public byte[] getValue() {
		return key.concat("|").getBytes();
	}
	
	public static Protocol getValue(String key) {
		Protocol command = null;
		
		if ("LST".equals(key)) {
			command = LIST;
		} else if ("DWN".equals(key)) {
			command = DOWNLOAD;
		} else if ("UPL".equals(key)) {
			command = UPLOAD;
		} else if ("UPC".equals(key)) {
			command = UPLOAD_CONFIRMATION;
		} else if ("LDF".equals(key)) {
			command = LIST_DELETED_FILES;
		} else if ("LDC".equals(key)) {
			command = LIST_DELETED_CONFIRMATION;
		} else if ("LEF".equals(key)) {
			command = LIST_EXISTENT_FILES;
		} else if ("LEC".equals(key)) {
			command = LIST_EXISTENT_CONFIRMATION;
		} else if ("DEL".equals(key)) {
			command = DELETE;
		} else if ("DEC".equals(key)) {
			command = DELETE_CONFIRMATION;
		} else {
			command = null;
		}
		
		return command;
	}
	
}
